
/* Recoding original TESS output into variables for analysis */

gen genderB=gender-1
gen marNo=marit_a-1
recode marNo 8=.
gen marNev=1 if mar_code==6
recode marNev .=0
gen employB=1 if employ==1
recode employB .=0
gen empFull=1 if employ2==1
recode empFull .=0
gen retiredB=1 if employ==3
recode retiredB .=0
gen RepubB=1 if party_a==1
recode RepubB .=0
gen DemocB=1 if party_a==2
recode DemocB .=0
gen liberal=1 if ideol_a==1
recode liberal .=0
gen conserv=1 if ideol_a==2
recode conserv .=0
gen moderate=1 if ideol_a==3
recode moderate .=0
gen libCat=1 if ideol_c==1
recode libCat .=2 if ideol_c==2
recode libCat .=3 if ideol_d==2
recode libCat .=4 if ideol_d==3
recode libCat .=5 if ideol_d==1
recode libCat .=6 if ideol_b==2
recode libCat .=7 if ideol_b==1
gen age=2003-born if born<2003 & born>0
gen whiteB=1 if race1==1
recode whiteB .=0
gen blackB=1 if race2==1
recode blackB .=0
gen latinoB=1 if latino==1
recode latinoB .=0
gen asianB=1 if race4==1
recode asianB .=1
gen christianB=1 if relig>0 & relig<4
recode christianB .=0
gen jewishB=1 if relig==4
recode jewishB .=0
gen noreligB=1 if relig==7
recode noreligB .=0
gen educYrs=educat_a if educat_a<18 & educat_a>0
recode educYrs .=14
gen educCat=edu_code if edu_code<5 & edu_code>0 
gen educ_ba=1 if educat_a==15
recode educ_ba .=0 if educat_a~=15
gen educ_ma=1 if educat_a==16
recode educ_ma .=0 if educat_a~=16
gen educ_pd=1 if educat_a==17
recode educ_pd .=0 if educat_a~=17
gen educ_vt=1 if educat_a==18
recode educ_vt .=0 if educat_a~=18
gen educ_cc=1 if educat_a==14
recode educ_cc .=0 if educat_a~=14
gen educ_sc=1 if educat_a==13
recode educ_sc .=0 if educat_a~=13
gen educ_hd=1 if educat_a==12
recode educ_hd .=0 if educat_a~=12
gen  educ_MP=1 if educ_ma==1
recode educ_MP .=1 if educ_pd==1
recode educ_MP .=0
gen educSC=1 if educ_sc==1
recode educSC .=1 if educ_ba==1
recode educSC .=1 if educ_MP==1
recode educSC .=0
gen incomB=1 if persinc1==2
recode incomB .=0 if persinc1==1
gen incomCat=persinc2 if persinc2>0 & persinc2<10
gen HincomCat=inc_code if inc_code>0 & inc_code<7
gen h1pos=1 if hisgroup==1
recode h1pos .=0
gen h2neg=1 if hisgroup==2
recode h2neg .=0
gen h3both=1 if hisgroup==3
recode h3both .=0
gen h4none=1 if hisgroup==4
recode h4none .=0
gen h5posNYT=1 if hisgroup==5
recode h5posNYT .=0
gen h6negNYT=1 if hisgroup==6
recode h6negNYT .=0
gen h7bothNYT=1 if hisgroup==7
recode h7bothNYT .=0
gen h8noneNYT=1 if hisgroup==8
recode h8noneNYT .=0
gen tradeB=1 if his1a==1
recode tradeB .=0 if his1a==2
gen tradeCat=1 if his1c==1
recode tradeCat .=2 if his1c==2
recode tradeCat .=3 if his1b==2
recode tradeCat .=4 if his1b==1
gen assistB=1 if his2a==1
recode assistB .=0 if his2a==2
gen assistCat=1 if his2c==1
recode assistCat .=2 if his2c==2
recode assistCat .=3 if his2b==2
recode assistCat .=4 if his2b==1
gen tradeAssist=1 if his2d==1
recode tradeAssist .=0 if his2d==2
gen tjobB=1 if his4==1
recode tjobB .=0 if his4==2
recode tjobB .=0 if his4==3
recode tjobB .=0 if his4==8
gen tjobCat=1 if his4==2
recode tjobCat .=2 if his4==3
recode tjobCat .=3 if his4==1
recode tjobCat .=2 if his4==8
gen newjobd=his5 if his5<5 & his5>0
gen trainedB=1 if his6a==1
recode trainedB .=0 if his6a==2
gen trainCat=1 if his6a==2
recode trainCat .=2 if his6b==3
recode trainCat .=3 if his6b==2
recode trainCat .=4 if his6b==1
gen trainSGD=1 if trainCat==3
recode trainSGD .=1 if trainCat==4
recode trainSGD .=0 if trainCat==2
recode trainSGD .=0 if trainCat==1
gen flexB=1 if his7a==1
recode flexB .=0 if his7a==2
gen parentB=1 if his7b==1
recode parentB .=0 if his7b==2
gen daycareB=1 if his7c==1
recode daycareB .=0 if his7c==2
gen famconB=1 if his8==1
recode famconB .=0 if his8==2
gen zip=zipcode
gen fipscode=fips
gen msacode=msa
gen divcode=cdiv
gen regcode=creg
gen regwest=1 if regcode==4
recode regwest .=0 if regcode~=4
gen regsouth=1 if regcode==3
recode regsouth .=0 if regcode~=3
gen regmidwest=1 if regcode==2
recode regmidwest .=0 if regcode~=2
gen regeast=1 if regcode==1
recode regeast .=0 if regcode~=1
gen his1group=1 if hisgroup<5
recode his1group .=0 if hisgroup>4
gen his2group=1 if hisgroup>4
recode his2group .=0 if hisgroup<5
gen ieducSCpos=educSC*h1pos 
gen ieducSCneg= educSC*h2neg
gen ieducSCboth=educSC*h3both
gen igenderBpos=genderB*h1pos
gen igenderBneg=genderB*h2neg
gen igenderBboth=genderB*h3both
gen iagepos=age*h1pos
gen iageneg=age*h2neg
gen iageboth=age*h3both
gen itrainSGDpos=trainSGD*h1pos
gen itrainSGDneg=trainSGD*h2neg
gen itrainSGDboth=trainSGD*h3both
sort caseid


/* Labeling new variables */

label var genderB "gender dummy=1 if female"
label var marNo "marital status dummy=1 if not married"
label var marNev "marital status (history) dummy=1 if never married"
label var employB "employment dummy=1 if full- or part-time employed"
label var empFull "employment (type) dummy=1 if full-time employed"
label var retiredB "retired person dummy=1 if retired"
label var RepubB "party affiliation dummy=1 if Republican" 
label var DemocB "party affiliation dummy=1 if Democrat" 
label var liberal "dummy=1 if self-identify as liberal"
label var conserv "dummy=1 if self-identify as conservative"
label var moderate "dummy=1 if self-identify as moderate"
label var libCat "liberal-ness in categories (1-strongly cons; 7=strongly lib)"
label var age "age in years"
label var whiteB "dummy for white"
label var blackB "dummy for black"
label var latinoB "dummy for latino"
label var asianB "dummy for asian"
label var christianB "dummy for Christian"
label var jewishB "dummy for Jewish"
label var noreligB "dummy=1 for answered no religious preference"
label var educYrs "education in years (approx. nb vocational/tech school beyond HS set to 14)"
label var educCat "education in categories (1=0-11yrs, 2=12yrs, 3=some college, 4=college+)"
label var educ_ba "dummy if BA highest level of education"
label var educ_ma "dummy if MA highest level of education"
label var educ_pd "dummy if medical or doctoral degree highest level of education"
label var educ_vt "dummy if vocational or technical school highest level of education"
label var educ_cc "dummy if community college or nursing school highest level of education"
label var educ_sc "dummy if some college highest level of education"
label var educ_hd "dummy if high school diploma highest level of education"
label var educ_MP "dummy if MA, medical, or doctoral degree highest level of education"
label var educSC "dummy if at least some college education"
label var incomB "personal income dummy=1 if $35k+"
label var incomCat "personal income in cats (1=0-$5k; 9=$30-35k)"
label var HincomCat "total household income in cats (1=0-$15k; 6=$75k+)"
label var h1pos "dummy for experimental group #1: positive trade frame"
label var h2neg "dummy for experimental group #2: negative trade frame"
label var h3both "dummy for experimental group #3: both trade frames"
label var h4none "dummy for experimental group #4: no trade frames"
label var h5posNYT "dummy for experimental group #5: postive frame & NYT endorsement"
label var h6negNYT "dummy for experimental group #6: negative frame & NYT endorsement"
label var h7bothNYT "dummy for experimental group #7: both frames & NYT endorsement"
label var h8noneNYT "dummy for experimental group #8: no frames & NYT endorsement"
label var tradeB "trade pref dummy=1 if favor increasing trade"
label var tradeCat "trade pref in categories (1=strong opp, 2=some opp, 3=some fav, 4=strong fav)"
label var assistB "adjustment assistance pref dummy=1 if favor assistance"
label var assistCat "assist pref in categories (1=strong opp, 2=some opp, 3=some fav, 4=strong fav)"
label var tradeAssist "assist/trade dummy=1 if more likely to support increasing trade if more assist"
label var tjobB "trade effects on job dummy=1 if think incr. trade makes job more secure 0=other answer"
label var tjobCat "trade effects on job in categories (1=less secure, 2=not clear, 3=more secure"
label var newjobd "difficulty finding new job (1=v easy, 2=some easy, 3=some difficult, 4=v difficult)"
label var trainedB "training dummy=1 if trained for specialized skills in current job"
label var trainCat "specialized training by categories (1=none, 2=a little, 3=some, 4=a great deal)"
label var trainSGD "dummy if at least some specialized training for job"
label var flexB "flex hours dummy=1 if flexible working hours offered in job" 
label var parentB "parental leave dummy=1 if parental leave offered in job" 
label var daycareB "daycare dummy=1 if daycare support offered in job" 
label var famconB "family considerations dummy=1 if family concerns affected job choice" 
label var zip "5-digit zip code"
label var fipscode "Census Federal Information Processing Standards code "
label var msacode "Census Metropolitan Statistical Area code"
label var divcode "Census Divisions (1-9)"
label var regcode "Census Regions (1-4)"
label var regwest "dummy for west Census region"
label var regsouth "dummy for south Census region"
label var regmidwest "dummy for midwest Census region"
label var regeast "dummy for northeast Census region"
label var his1group "dummy indicating in experimental groups #1 through #4"
label var his2group "dummy indicating in experimental subgroups #5 through #8"


